package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.AttackDetectionAttrHandler;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.VpnCateIdAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @version V1.0
 * @author:lxb
 * @Package
 * @date:2021/4/15
 */
@Service
@AttrHandler(VpnCateIdAttrHandler.class)
public class VpnCateIdAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr attr22=kiteInst.getAttr("200002822");//vpn域名
        KiteAttr attr20=kiteInst.getAttr("200002820");//VPN分类

        KiteAttr attr33=kiteInst.getAttr("200002833");//APN名称
        KiteAttr attr34=kiteInst.getAttr("200002834");//VPDN业务类型
        KiteAttr attr35=kiteInst.getAttr("200002835");//手机号码是否与AAA中ID绑定
        KiteAttr attr36=kiteInst.getAttr("200002836");//使用联通AAA客户终端IP地址类型
        KiteAttr attr37=kiteInst.getAttr("200002837");//企业AAA中心端IP（LNS IP）
        KiteAttr attr38=kiteInst.getAttr("200002838");//客户拟开通终端数量
        KiteAttr attr39=kiteInst.getAttr("200002839");//客户终端IP地址段

        KiteAttr attr24=kiteInst.getAttr("200002824");//是否新增分支点地址段

        KiteAttr attr27=kiteInst.getAttr("200002827");//中心端局域网使用的地址段

        KiteAttr attr28=kiteInst.getAttr("200002828");//电子政务外网
        List<KiteAttrValue> attrValues = attr28.getAttrValues();
        if(KiteStringUtils.equals(kiteAttr.getValue(),"100005404")){//新建域名
            attr22.setIsEdit("T");
            attr22.setPageUrl("");
            attr22.setAttrValueTypeId("98C");
            attr27.setShowType("D");
        }if(KiteStringUtils.equals(kiteAttr.getValue(),"100005405")){//域名选择
            attr22.setIsEdit("F");
            attr22.setAttrValueTypeId("98F");
            attr22.setPageUrl("AttrSelectModal");
            attr27.setShowType("E");
        }
        if(KiteStringUtils.equals(attr20.getValue(),"100004678")&&KiteStringUtils.equals(kiteAttr.getValue(),"100005404")){//中心点
            attr33.setShowType("D");
            attr34.setShowType("D");
            attr35.setShowType("D");
            attr36.setShowType("D");
            attr37.setShowType("D");
            attr38.setShowType("D");
            attr39.setShowType("D");
            attrValues=attrValues.stream().filter(attrvalue->!KiteStringUtils.equals("100004681",attrvalue.getAttrValue())).collect(Collectors.toList());
            attr28.setAttrValues(attrValues);
        }else {//分支点
            if(KiteStringUtils.equals(kiteAttr.getValue(),"100005404")){
                attr24.setShowType("D");
            }
            attr33.setShowType("E");
            attr34.setShowType("E");
            attr35.setShowType("E");
            attr36.setShowType("E");
            attr37.setShowType("E");
            attr38.setShowType("E");
            attr39.setShowType("E");
        }
    /*    operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr22);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr27);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr28);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr24);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr33);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr34);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr35);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr36);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr37);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr38);
        operateSceneInstService.setAttr(data.getSceneInstId(), inst.getInstType(), inst.getInstId(), attr39);*/

    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
